<!DOCTYPE html	PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:s="http://sduept.security.el/func"
	template="/template/template_dialog.xhtml">
	<ui:define name="head">
	<title>知识库选择器</title>
	<style type="text/css">
/* .value {
	font-weight: bold;
}

.ui-tree {
	width: 400px;
	position: relative;
	height: 300px;
	overflow-y: scroll;
}

input[type="text"] {
	height: 21px;
} */
</style>
</ui:define>
		

<!-- 
使用方法
在页面中
<p:commandButton value="选择知识" icon="ui-icon-extlink" actionListener="#{自己的Controller.chooseKnowledge()}">
	<p:ajax event="dialogReturn"  listener="#{自己的Controller.onSelectorChosen}"  />
</p:commandButton>
在自己的业务controller中 添加如下方法
public void chooseKnowledge() {
        Map<String,Object> options = new HashMap<String, Object>();
        options.put("resizable", true);
        options.put("draggable", true);
        options.put("modal", true);
        options.put("reflow", true);//堆叠
       // options.put("width", 1000);
        options.put("height", 700);
        options.put("contentWidth", 1000);
        options.put("contentHeight", 800);
        Map<String,List<String>> params = new HashMap<>();
        RequestContext.getCurrentInstance().openDialog("/ui/common/knowledgebase_selector_single.xhtml", options, params);
    }
	public void onSelectorChosen(SelectEvent event) {
		//返回的是选择的对象
		KnowledgeBase  kb = (KnowledgeBase ) event.getObject();
	}
 -->

 <ui:define name="content">
     <h:form id="toolbarForm">
			<p:toolbar id="toolbar">
				<f:facet name="left">
					<p:outputLabel  value="隐患等级：" style="margin-left:10px;" />
					<h:selectOneMenu id="hdLevel" value="#{knowledgeBaseSelectorController.queryParam.hdLevel}"	style="width:130px;margin-right:20px;height:30px">
						<f:selectItem itemLabel="全部" itemValue="" />
						<f:selectItems value="#{knowledgeBaseSelectorController.gradeList}" var="hdlItem" />
					</h:selectOneMenu>
					<p:outputLabel  value="隐患来源：" style="margin-left:10px;" />
					<h:selectOneMenu id="hdSource" value="#{knowledgeBaseSelectorController.queryParam.hdSource}"	style="width:130px;margin-right:20px;height:30px">
						<f:selectItem itemLabel="全部" itemValue="" />
						<f:selectItems value="#{knowledgeBaseSelectorController.sourceList}" var="hdsItem" />
					</h:selectOneMenu>
					<p:outputLabel  value="问题归类：" style="margin-left:10px;" />
					<h:selectOneMenu id="quesType" value="#{knowledgeBaseSelectorController.queryParam.quesType}"	style="width:130px;margin-right:20px;height:30px">
						<f:selectItem itemLabel="全部" itemValue="" />
						<f:selectItems value="#{knowledgeBaseSelectorController.quesList}" var="qtItem" />
					</h:selectOneMenu>	
					<p:outputLabel  value="原因归类：" style="margin-left:10px;" />
					<h:selectOneMenu id="reasonType" value="#{knowledgeBaseSelectorController.queryParam.reasonType}" style="width:130px;margin-right:20px;height:30px">
						<f:selectItem itemLabel="全部" itemValue="" />
						<f:selectItems value="#{knowledgeBaseSelectorController.reasonList}" var="rtItem" />
					</h:selectOneMenu>	
					<br />
					<p:outputLabel value="评价专家：" style="margin-left:10px;" />
				   	<p:autoComplete id="ename"  dropdown="true" placeholder="输入专家首字母查询" scrollHeight="400"
						value="#{knowledgeBaseController.queryParam.expertName}" style="margin-right:20px;"
					   completeMethod="#{knowledgeBaseController.complateExpert}"	>								  
					</p:autoComplete>			
					<p:commandButton icon="ui-icon-search" value="查询" id="query2" update="deviceForm:dataTb " oncomplete="getTableScrollHeight();" 
						actionListener="#{knowledgeBaseSelectorController.query()}"	style="margin-left:5px;">
					</p:commandButton>
					<p:commandButton icon="ui-icon-refresh" value="重置" style="margin-left:5px;"
						oncomplete="getTableScrollHeight();" actionListener="#{knowledgeBaseSelectorController.resetQuery()}"
						update="deviceForm:dataTb    hdLevel hdSource quesType reasonType ename" />
					<p:commandButton value="确定"  update="selectedEquipmentJson" style="margin-left:5px;" icon="ui-icon-plus" oncomplete="closeAndSave();"
						actionListener="#{knowledgeBaseSelectorController.setQuesDesc}"/>
					<h:inputHidden id="selectedEquipmentJson" value="#{knowledgeBaseSelectorController.selectedQuesDesc}" />
				</f:facet>
				
			</p:toolbar>
		</h:form>
		
	<h:form id="deviceForm">
		<p:messages id="messages" showDetail="true">
		</p:messages>
		<!-- <p:dataTable id="dataTb" var="item" value="#{knowledgeBaseSelectorController.kbs}" liveResiz="true"
					selection="#{knowledgeBaseSelectorController.selectKb}" rowKey="#{item.id}"
					emptyMessage="无记录"   scrollHeight="550"
					widgetVar="dataTb" scrollable="true" > -->
					
			<p:dataTable id="dataTb" var="item" value="#{knowledgeBaseSelectorController.kbs}"
					selection="#{knowledgeBaseSelectorController.selectKb}" rowKey="#{item.id}" style="margin-bottom:0;"
					emptyMessage="无记录" rows="8" paginator="true" rowIndexVar="ite"
					paginatorTemplate="{Customization} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}	{RowsPerPageDropdown}"
					widgetVar="dataTb" 
					 paginatorPosition="bottom" ><!-- rowsPerPageTemplate="8,20,50" -->
					<p:ajax event="rowSelectRadio" listener="#{knowledgeBaseSelectorController.RowSelect}"></p:ajax>
					<p:column selectionMode="single" width="3" style="text-align:center" />
					
					<p:column width="5" headerText="专家">
						<h:outputText value="#{item.expertName}" />
					</p:column>
					<p:column width="18" headerText="记录时间">
						<h:outputText value="#{item.createdTime}">
							<f:convertDateTime pattern="yyyy-MM-dd" />
						</h:outputText>
					</p:column>
					<p:column width="15" headerText="管辖专业">
						<h:outputText value="#{item.jSpecialty}" />
					</p:column>
					<p:column width="15" headerText="隐患等级">
						<h:outputText value="#{item.hiddenDangerGrade}" />
					</p:column>
					<p:column width="15" headerText="问题归类">
						<h:outputText value="#{item.hiddenDangerQuesClass}" />
					</p:column>
					<p:column width="15" headerText="原因归类">
						<h:outputText value="#{item.hiddenDangerReasonClass}" />
					</p:column>
					<p:column width="15" headerText="隐患来源">
						<h:outputText value="#{item.hiddenDangerSources}" />
					</p:column>
					<p:column width="30" headerText="隐患描述">
						<!-- <h:outputText value="#{item.hiddenDangerDesc}"/> -->
						<h:inputTextarea value="#{item.hiddenDangerDesc}" style="color:black;"  cols="15" readonly="true"/>
					</p:column>
					<p:column width="30" headerText="整改意见">
						<!-- <h:outputText value="#{item.rectificationPlan}" /> -->
						<h:inputTextarea value="#{item.rectificationPlan}"  style="color:black;" cols="15" readonly="true"/>
					</p:column>
				</p:dataTable>
	</h:form>
	<script>
	  function closeAndSave(){
				var index = parent.layer.getFrameIndex(window.name);
				var descData = document.getElementById("toolbarForm:selectedEquipmentJson").value;
				if(parent.dialogReturn){
					parent.dialogReturn(index,descData);
				}
				parent.layer.close(index);
			}
	</script>
	
	
   </ui:define>
	
</ui:composition>
